package 删除有序数组的重复项;

public class Solution {
    public static int removeDuplicates(int[] nums) {
        int n=nums.length;
        int x=0;
        int y=1;
        if (n==0){
            return 0;
        }
        while (y<n){
            if (nums[x]!=nums[y]){
                x++;
                nums[x]=nums[y];

                y++;
            }
            else {
                y++;
            }
        }
        return x+1;
    }

    public static void main(String[] args) {
        int[] nums={0,0,1,1,1,2,2,3,3,4};
        removeDuplicates(nums);
    }
}
